<!DOCTYPE HTML>
<html lang="en" >
    <!-- Start book NoSQL简介 -->
    <head>
        <!-- head:start -->
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <title>hash | NoSQL简介</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 2.6.7">
        
        
        <meta name="HandheldFriendly" content="true"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
        <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
        
    <link rel="stylesheet" href="../gitbook/style.css">
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-toggle-chapters/toggle.css">
        
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-highlight/website.css">
        
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-search/search.css">
        
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-fontsettings/website.css">
        
    
    

        
    
    
    <link rel="next" href="../part2/4_4.html" />
    
    
    <link rel="prev" href="../part2/4_2.html" />
    

        <!-- head:end -->
    </head>
    <body>
        <!-- body:start -->
        
    <div class="book"
        data-level="4.3"
        data-chapter-title="hash"
        data-filepath="part2/4_3.md"
        data-basepath=".."
        data-revision="Thu Nov 02 2017 21:26:40 GMT+0800 (CST)"
        data-innerlanguage="">
    

<div class="book-summary">
    <nav role="navigation">
        <ul class="summary">
            
            
            
            

            

            
    
        <li class="chapter " data-level="0" data-path="index.html">
            
                
                    <a href="../index.html">
                
                        <i class="fa fa-check"></i>
                        
                        简介
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1" data-path="part1/1.html">
            
                
                    <a href="../part1/1.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.</b>
                        
                        安装
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2" data-path="part1/2.html">
            
                
                    <a href="../part1/2.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.</b>
                        
                        配置
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3" data-path="part1/3.html">
            
                
                    <a href="../part1/3.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.</b>
                        
                        服务器与客户端
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4" data-path="part2/4.html">
            
                
                    <a href="../part2/4.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.</b>
                        
                        数据操作
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.1" data-path="part2/4_1.html">
            
                
                    <a href="../part2/4_1.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.1.</b>
                        
                        string
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.2" data-path="part2/4_2.html">
            
                
                    <a href="../part2/4_2.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.2.</b>
                        
                        键命令
                    </a>
            
            
        </li>
    
        <li class="chapter active" data-level="4.3" data-path="part2/4_3.html">
            
                
                    <a href="../part2/4_3.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.3.</b>
                        
                        hash
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.4" data-path="part2/4_4.html">
            
                
                    <a href="../part2/4_4.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.4.</b>
                        
                        list
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.5" data-path="part2/4_5.html">
            
                
                    <a href="../part2/4_5.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.5.</b>
                        
                        set
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.6" data-path="part2/4_6.html">
            
                
                    <a href="../part2/4_6.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.6.</b>
                        
                        zset
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="5" data-path="part3/5.html">
            
                
                    <a href="../part3/5.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.</b>
                        
                        与python交互
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="5.1" data-path="part3/5_1.html">
            
                
                    <a href="../part3/5_1.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.1.</b>
                        
                        方法
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.2" data-path="part3/5_2.html">
            
                
                    <a href="../part3/5_2.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.2.</b>
                        
                        string-增加
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.3" data-path="part3/5_3.html">
            
                
                    <a href="../part3/5_3.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.3.</b>
                        
                        string-获取
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.4" data-path="part3/5_4.html">
            
                
                    <a href="../part3/5_4.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.4.</b>
                        
                        string-修改
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.5" data-path="part3/5_5.html">
            
                
                    <a href="../part3/5_5.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.5.</b>
                        
                        string-删除
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.6" data-path="part3/5_6.html">
            
                
                    <a href="../part3/5_6.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.6.</b>
                        
                        获取键
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="6" data-path="part4/6.html">
            
                
                    <a href="../part4/6.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.</b>
                        
                        搭建主从
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7" data-path="part4/7.html">
            
                
                    <a href="../part4/7.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.</b>
                        
                        搭建集群
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="7.1" data-path="part4/7_1.html">
            
                
                    <a href="../part4/7_1.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.1.</b>
                        
                        配置机器1
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.2" data-path="part4/7_2.html">
            
                
                    <a href="../part4/7_2.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.2.</b>
                        
                        配置机器2
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.3" data-path="part4/7_3.html">
            
                
                    <a href="../part4/7_3.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.3.</b>
                        
                        创建集群
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.4" data-path="part4/7_4.html">
            
                
                    <a href="../part4/7_4.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.4.</b>
                        
                        Python交互
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="8" data-path="8.html">
            
                
                    <a href="../8.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.</b>
                        
                        总结与作业
                    </a>
            
            
        </li>
    


            
            <li class="divider"></li>
            <li>
                <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
                    Published with GitBook
                </a>
            </li>
            
        </ul>
    </nav>
</div>

    <div class="book-body">
        <div class="body-inner">
            <div class="book-header" role="navigation">
    <!-- Actions Left -->
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../" >NoSQL简介</a>
    </h1>
</div>

            <div class="page-wrapper" tabindex="-1" role="main">
                <div class="page-inner">
                
                
                    <section class="normal" id="section-">
                    
                        <h1 id="hash">hash</h1>
<ul>
<li>hash&#x7528;&#x4E8E;&#x5B58;&#x50A8;&#x5BF9;&#x8C61;&#xFF0C;&#x5BF9;&#x8C61;&#x7684;&#x7ED3;&#x6784;&#x4E3A;&#x5C5E;&#x6027;&#x3001;&#x503C;</li>
<li>&#x503C;&#x7684;&#x7C7B;&#x578B;&#x4E3A;string</li>
</ul>
<h4 id="&#x589E;&#x52A0;&#x3001;&#x4FEE;&#x6539;">&#x589E;&#x52A0;&#x3001;&#x4FEE;&#x6539;</h4>
<ul>
<li>&#x8BBE;&#x7F6E;&#x5355;&#x4E2A;&#x5C5E;&#x6027;</li>
</ul>
<pre><code>hset key field value
</code></pre><ul>
<li>&#x4F8B;1&#xFF1A;&#x8BBE;&#x7F6E;&#x952E;&apos;py2&apos;&#x7684;&#x5C5E;&#x6027;&apos;name&apos;&#x4E3A;&apos;hr&apos;</li>
</ul>
<pre><code>hset &apos;py2&apos; &apos;name&apos; &apos;hr&apos;
</code></pre><ul>
<li>&#x8BBE;&#x7F6E;&#x591A;&#x4E2A;&#x5C5E;&#x6027;</li>
</ul>
<pre><code>hmset key field1 value1 field2 value2 ...
</code></pre><ul>
<li>&#x4F8B;2&#xFF1A;&#x8BBE;&#x7F6E;&#x952E;&apos;py3&apos;&#x7684;&#x5C5E;&#x6027;&apos;name&apos;&#x4E3A;&apos;dx&apos;&#x3001;&#x5C5E;&#x6027;&apos;gender&apos;&#x4E3A;&apos;1&apos;&#x3001;&#x5C5E;&#x6027;&apos;birthday&apos;&#x4E3A;&apos;2017-1-1&apos;</li>
</ul>
<pre><code>hmset &apos;py3&apos; &apos;name&apos; &apos;dx&apos; &apos;gender&apos; &apos;1&apos; &apos;birthday&apos; &apos;2017-1-1&apos;
</code></pre><h4 id="&#x83B7;&#x53D6;">&#x83B7;&#x53D6;</h4>
<ul>
<li>&#x83B7;&#x53D6;&#x6307;&#x5B9A;&#x952E;&#x6240;&#x6709;&#x7684;&#x5C5E;&#x6027;</li>
</ul>
<pre><code>hkeys key
</code></pre><ul>
<li>&#x4F8B;3&#xFF1A;&#x83B7;&#x53D6;&#x952E;&apos;py3&apos;&#x7684;&#x6240;&#x6709;&#x5C5E;&#x6027;</li>
</ul>
<pre><code>hkeys &apos;py3&apos;
</code></pre><ul>
<li>&#x83B7;&#x53D6;&#x4E00;&#x4E2A;&#x5C5E;&#x6027;&#x7684;&#x503C;</li>
</ul>
<pre><code>hget key field
</code></pre><ul>
<li>&#x4F8B;4&#xFF1A;&#x83B7;&#x53D6;&#x952E;&apos;py2&apos;&#x5C5E;&#x6027;&apos;name&apos;&#x7684;&#x503C;</li>
</ul>
<pre><code>hget &apos;py2&apos; &apos;name&apos;
</code></pre><ul>
<li>&#x83B7;&#x53D6;&#x591A;&#x4E2A;&#x5C5E;&#x6027;&#x7684;&#x503C;</li>
</ul>
<pre><code>hmget key field1 field2 ...
</code></pre><ul>
<li>&#x4F8B;5&#xFF1A;&#x83B7;&#x53D6;&#x952E;&apos;py3&apos;&#x5C5E;&#x6027;&apos;name&apos;&#x3001;&apos;gender&apos;&#x3001;&apos;birthday&apos;&#x7684;&#x503C;</li>
</ul>
<pre><code>hmget &apos;py3&apos; &apos;name&apos; &apos;gender&apos; &apos;birthday&apos;
</code></pre><ul>
<li>&#x83B7;&#x53D6;&#x6240;&#x6709;&#x5C5E;&#x6027;&#x7684;&#x503C;</li>
</ul>
<pre><code>hvals key
</code></pre><ul>
<li>&#x4F8B;6&#xFF1A;&#x83B7;&#x53D6;&#x952E;&apos;py3&apos;&#x6240;&#x6709;&#x5C5E;&#x6027;&#x7684;&#x503C;</li>
</ul>
<pre><code>hvals &apos;py3&apos;
</code></pre><h4 id="&#x5220;&#x9664;">&#x5220;&#x9664;</h4>
<ul>
<li>&#x5220;&#x9664;&#x6574;&#x4E2A;hash&#x952E;&#x53CA;&#x503C;&#xFF0C;&#x4F7F;&#x7528;del&#x547D;&#x4EE4;</li>
<li>&#x5220;&#x9664;&#x5C5E;&#x6027;&#xFF0C;&#x5C5E;&#x6027;&#x5BF9;&#x5E94;&#x7684;&#x503C;&#x4F1A;&#x88AB;&#x4E00;&#x8D77;&#x5220;&#x9664;</li>
</ul>
<pre><code>hdel key field1 field2 ...
</code></pre><ul>
<li>&#x4F8B;7&#xFF1A;&#x83B7;&#x53D6;&#x952E;&apos;py3&apos;&#x7684;&#x5C5E;&#x6027;&apos;gender&apos;&#x3001;&apos;birthday&apos;</li>
</ul>
<pre><code>hdel &apos;py3&apos; &apos;gender&apos; &apos;birthday&apos;
</code></pre>
                    
                    </section>
                
                
                </div>
            </div>
        </div>

        
        <a href="../part2/4_2.html" class="navigation navigation-prev " aria-label="Previous page: 键命令"><i class="fa fa-angle-left"></i></a>
        
        
        <a href="../part2/4_4.html" class="navigation navigation-next " aria-label="Next page: list"><i class="fa fa-angle-right"></i></a>
        
    </div>
</div>

        
<script src="../gitbook/app.js"></script>

    
    <script src="../gitbook/plugins/gitbook-plugin-toggle-chapters/toggle.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-search/lunr.min.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-search/search.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-sharing/buttons.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-fontsettings/buttons.js"></script>
    

<script>
require(["gitbook"], function(gitbook) {
    var config = {"toggle-chapters":{},"highlight":{},"search":{"maxIndexSize":1000000},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2}};
    gitbook.start(config);
});
</script>

        <!-- body:end -->
    </body>
    <!-- End of book NoSQL简介 -->
</html>
